fix(agent): use unique block ids for text/thinking stream events#2002
fix(agent): use unique block ids for text/thinking stream events#2002liulangjietou wants to merge 1 commit into
Conversation
Text/thinking block events were emitted with hardcoded block ids
("text"/"thinking"), violating the documented contract that blockId
uniquely identifies each content block. Allocate a unique id per block
in ModelCallBlockLifecycle (consistent across Start/Delta/End of the
same block), following the existing tool-call block precedent.
Fixes agentscope-ai#1899
|
|
|
CLA Not Signed The Contributor License Agreement (CLA) check is currently pending on this PR ( @liulangjietou please sign the CLA via the CLA assistant badge in the comment above, or visit https://cla-assistant.io/agentscope-ai/agentscope-java. Once signed, the Automated check by github-manager-bot |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
Fixes unique block IDs for text/thinking stream events using AtomicReference + UUID. Both batch and streaming paths updated symmetrically. Good test coverage. Behavior change: blockId format changes - document in release notes.
(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)
AgentScope-Java Version
2.0.0-RC4 (main, latest)
Description
ReActAgent'''s streaming block events for text and thinking blocks were emittedwith hardcoded block ids ("text" / "thinking"), which violates the documented
contract that blockId uniquely identifies each content block. Tool-call block
events in the same code path already use a unique
toolId, so this bringstext/thinking blocks in line with that existing precedent.
Fix:
ModelCallBlockLifecyclenow lazily allocates a unique block id (samegeneration scheme as
replyId:UUID.randomUUID().toString().replace("-", ""))when a text/thinking block starts, and reuses that id across the block'''s
Start/Delta/End events. Two hardcoded call sites were fixed — the primary
emitBlockEventspath and a second duplicate path further down the file.No public API changes; no existing test asserted on the literal "text"/"thinking"
ids, so this is behavior-compatible for all in-repo consumers.
Fixes #1899
Checklist
mvn spotless:applymvn test)